import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;
import java.util.Map;

public class UdpTranslateServer extends UdpEchoServe {
    private final Map<String,String> dictionary = new HashMap<>();
    public UdpTranslateServer(int port) throws SocketException {
        super(port);
        dictionary.put("chicken","🐓");
        dictionary.put("dog","狗");
        dictionary.put("cat","🐱");
        dictionary.put("pig","🐖");
        dictionary.put("apple","🍎");
    }

    @Override
    public String process(String request) {
        return dictionary.getOrDefault(request,"未查询到该词汇");
    }

    public static void main(String[] args) throws IOException {
        UdpTranslateServer server = new UdpTranslateServer(9090);
        server.start();
    }
}
